/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ventasimple.modelo;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Claudio
 */
@Entity
@Table(name = "pu_foto")
public class PublicacionFoto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    
    @Column(name = "ID")
    private Integer id;
        
    @JoinColumn(name = "ID_PUBLICACION", referencedColumnName = "ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private Publicacion publicacion;
   
    
    @NotNull
    @Column(name = "ORDEN")
    private Integer orden;
    @Size(max = 255)
    @Column(name = "DESCRIPCION")
    private String descripcion;
    
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "PATH_FOTO")
    private String pathFoto;
    
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "PRINCIPAL", length = 1)
    private String principal;

    public PublicacionFoto() {
    }

    public PublicacionFoto(Integer id) {
        this.id = id;
    }

    public PublicacionFoto(Integer id, Publicacion publicacion, Integer orden, String pathFoto, String principal) {
        this.id = id;
        this.publicacion = publicacion;
        this.orden = orden;
        this.pathFoto = pathFoto;
        this.principal = principal;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Publicacion getPublicacion() {
        return publicacion;
    }

    public void setPublicacion(Publicacion publicacion) {
        this.publicacion = publicacion;
    }

    public Integer getOrden() {
        return orden;
    }

    public void setOrden(Integer orden) {
        this.orden = orden;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getPathFoto() {
        return pathFoto;
    }

    public void setPathFoto(String pathFoto) {
        this.pathFoto = pathFoto;
    }

    public String getPrincipal() {
        return principal;
    }

    public void setPrincipal(String principal) {
        this.principal = principal;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PublicacionFoto)) {
            return false;
        }
        PublicacionFoto other = (PublicacionFoto) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return pathFoto;//"com.ereconquista.modelo.PublicacionFoto[ id=" + id + " ]";
    }
    
}
